package io.renren.utils.wx;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Data
@Configuration
public class WxConfig {

    /**
     * 微信公众号的 AppId
     */
    @Value("${wxappid}")
    private String appId;

    /**
     * 微信公众号的 AppSecret
     */
    @Value("${wxappsecret}")
    private String appSecret;

    /**
     * 微信 获取用户信息的 URL
     */
    private String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?";

    /**
     * 微信 网页code码授权的 URL
     */
    private String codeAccessToken = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";

    /**
     * 微信 AccessToken和openId检查的 URL
     */
    private String wxtokencheck = "https://api.weixin.qq.com/sns/auth?access_token=%s&openid=%s";


    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
